//
//  DKFooterView.swift
//  Sina
//
//  Created by 赵柏清 on 16/8/4.
//  Copyright © 2016年 DarkZhao. All rights reserved.
//

import UIKit

class DKFooterView: UIView {
    
    var turnCount : String? {
        didSet {
            guard let OTurn = turnCount else {
                return
            }
            
            commentBtn.setTitle(OTurn, forState: UIControlState.Normal)
            
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    private func setupUI(){
        
        addSubview(commentBtn)
        addSubview(turnBtn)
        addSubview(goodBtn)
        
//    }
//    // MARK: 布局子控件
//    override func layoutSubviews() {
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(self)
            make.top.equalTo(self)
            make.bottom.equalTo(self)
            make.right.equalTo(turnBtn.snp_left).offset(0)
            
            make.width.equalTo(turnBtn)
            
        }
        
        turnBtn.snp_makeConstraints { (make) -> Void in
            
            make.top.equalTo(self)
            make.bottom.equalTo(self)
            make.left.equalTo(commentBtn.snp_right)
            make.right.equalTo(goodBtn.snp_left)
            
            make.width.equalTo(goodBtn)
            
        }
        
        goodBtn.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(turnBtn.snp_right)
            make.top.equalTo(self)
            make.right.equalTo(self)
            make.bottom.equalTo(self)
            
            make.width.equalTo(commentBtn)
            
        }
        
    }
    
    // MARK:懒加载
    /// 转发按钮
    lazy var commentBtn : UIButton = {
        let comment = UIButton(type: UIButtonType.Custom)
        
        // 设置背景图片
        comment.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        
        comment.setTitle("转发", forState: UIControlState.Normal)
        
        comment.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
        
        // 修改按钮的字体大小
        comment.titleLabel?.font = UIFont.systemFontOfSize(14.0)
        
        return comment
    }()
    /// 评论按钮
    lazy var turnBtn : UIButton = {
        let turn = UIButton(type: UIButtonType.Custom)
        
        // 设置背景图片
        turn.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
        
        turn.setTitle("评论", forState: UIControlState.Normal)
        
        turn.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
        
        // 修改按钮的字体大小
        turn.titleLabel?.font = UIFont.systemFontOfSize(14.0)
        
        return turn
    }()
    
    lazy var goodBtn : UIButton = {
        let good = UIButton(type: UIButtonType.Custom)
        
        // 设置背景图片
        good.setImage(UIImage(named: "timeline_icon_like"), forState: UIControlState.Normal)
        
        good.setTitle("点赞", forState: UIControlState.Normal)
        good.setTitle("已点赞", forState: UIControlState.Highlighted)
        
        good.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
        
        // 修改按钮的字体大小
        good.titleLabel?.font = UIFont.systemFontOfSize(14.0)
        
        return good

    }()

}
